<?php

declare(strict_types=1);

namespace Zyucv7\Components\AI\LLM\ClientType;

use Zyucv7\Components\AI\LLM\Client as LLMClient;
use Zyucv7\Components\AI\LLM\Exceptions\ClientException as LLMClientException;

/**
 * 海螺AI
 */
class Minimax extends LLMClient
{

    protected string $apiKey = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJHcm91cE5hbWUiOiLlsI_onrrluL03MjIwIiwiVXNlck5hbWUiOiLlsI_onrrluL03MjIwIiwiQWNjb3VudCI6IiIsIlN1YmplY3RJRCI6IjE4ODEzMjAyMTg4MTUzNjk1MjgiLCJQaG9uZSI6IjEzMjg2MzY1MDQzIiwiR3JvdXBJRCI6IjE4ODEzMjAyMTg4MDY5ODA5MjAiLCJQYWdlTmFtZSI6IiIsIk1haWwiOiIyNzk2Mzk0MzlAcXEuY29tIiwiQ3JlYXRlVGltZSI6IjIwMjUtMTAtMjkgMDk6Mzg6NTMiLCJUb2tlblR5cGUiOjEsImlzcyI6Im1pbmltYXgifQ.YtysOzsqrPN_o-1840vfvsnxyVa_s3MjvdzL9diAWxf3lrtOhNf0Ag1QD3C-TH9bfpnZBpH6lPL6gCNR7bovavG6rISOlULo3Fsq5UCF0hwcJJg7jva6jsbUlOdjpGfg5opzlTXTu5-rQPOm_mZuC4ABXjnbhYbRPOFdLP5I3t3SM4lBrFh_iClns8eOAOUOh1ByyxEy4a-a_dckz_yqJui2zk3Gqrk0pYqTtSwUHu03J-OcemLOyPbJub5A_doaEc1edCDl-5-Z9zO3ZLdhHnJocNhoAFvoPiUgfK_VSoZarYteudtL-jH-aNPsyJ11Dvb87Rv29q1njm6pry_oIw'; // API Key
    protected string $baseUrl = 'https://api.minimaxi.com'; // API 公用地址
    protected string $model = 'MiniMax-M2'; // 默认免费模型
    protected string $sendUrl = '/anthropic';

    private function getContent() {
        return '{
            "model": "'.$this->model.'",
            "do_sample": true,
            "stream": false,
            "thinking": {
                "type": "disabled"
            },
            "temperature": 0.6,
            "top_p": 0.95,
            "stream": false,
            "tool_stream": false,
            "response_format": {
                "type": "text"
            },
            "messages": [
                {
                    "role": "system",
                    "content": "'.$this->systemPrompt.'"
                },
                {
                    "role": "user",
                    "content": "'.$this->userPrompt.'"
                }
            ]
        }';
    }
    protected function buildOptions(): void
    {
        if(!$this->systemPrompt || !$this->userPrompt) {
            throw LLMClientException::InvalidArgument('System prompt or user prompt is not set.');
        }

        $this->jsonStr = $this->getContent();
    }
}
